const app = getApp();
const api = require('../../utils/api');
const md5 = require('../../utils/md5');

Page({
    data: {
        id: '',
        orderDetail: '',
    },
    onLoad(options) {
        if(options.id) {
            this.setData({
                id: options.id
            });
        }
        this.getOrderDetail();
    },
    onShow() {

    },

    getOrderDetail() { //获取订单详情
        api.post(`/coupon/order/detail?orderId=${this.data.id}`)
            .then(res => {
                // 整理数据
                let data = res;
                data.couponPrice = res.couponPrice.toFixed(2);
                data.payAmountShow = res.payAmount.toFixed(2);
                data.createTime = app.filterDate(res.createTime);
                data.payTime = res.payTime ? app.filterDate(res.payTime) : '-';
                
                this.setData({
                    orderDetail: data,
                });
            })
    },
})